﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 设计模式
{
    public partial class FrmSingletonPattern_Child : Form
    {
        private static FrmSingletonPattern_Child instance = null;
        private static int count = 1;
        
        private FrmSingletonPattern_Child()
        {
            InitializeComponent();
            label1.Text = "这是第" + count.ToString() + "次打开本窗体";
            count++;
        }
        public static FrmSingletonPattern_Child Instance
        {
            get {
                if (instance == null)
                    instance = new FrmSingletonPattern_Child();
                return instance; 
            }

        }

        private void FrmSingletonPattern_Child_FormClosed(object sender, FormClosedEventArgs e)
        {
            instance = null;
        }
    }
}
